package com.shawn;

import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
        long[] A=new long[n];
        for(int i=0;i<n;i++){
            A[i]=s.nextLong();
        }
        long count=1;
        long[]threenum;
        int start = 0;
        for(int i=2;i<n;i++){
            threenum=getThreeDifferentNum(A,start,i);
            if((threenum[1]>threenum[2] && threenum[1]>threenum[0])||(threenum[1]<threenum[2] && threenum[1]<threenum[0]))
            {
                count++;
                start=i;
            }
        }
        System.out.println(count);
    }
    public static long[] getThreeDifferentNum(long[] data,int start,int pos){
        long []result=new long[3];
        int index = pos-1;
        int index2 = 0;
        result[0]=data[pos];
        while(index>=start && index2<2){
            if(result[index2] != data[index])
                result[++index2]=data[index];
            index--;
        }
        if(index2!=2){
            while(index2<2){
                result[1+index2]=result[index2];
                index2++;
            }
        }
        return result;
    }
}